//
//  GRCommentModel.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/7/13.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRCommentModel.h"

@implementation GRCommentModel


- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic{
    NSArray *array = dic[@"evaluateImgs"];
    if (Array(array)) {
        NSMutableArray *imgArray = [NSMutableArray array];
        NSMutableArray * imgeUrlArr = [NSMutableArray array];
        for (NSDictionary *dic in array) {
            GRCommentImageModel *model = [GRCommentImageModel yy_modelWithDictionary:dic];
            [imgArray addObject:model];
            [imgeUrlArr addObject:model.geiImg];
        }
        self.comentImageArr = imgeUrlArr;
        self.evaluateImgs = imgArray;
    }
    
        NSArray * evaluteArray = dic[@"imgArray"];
        if (Array(evaluteArray )) {
            NSMutableArray * imgeUrlArr = [NSMutableArray array];
            NSMutableArray * evaArr = [NSMutableArray array];
            for (NSDictionary * dic in evaluteArray) {
                GRCommentImageModel *model = [GRCommentImageModel yy_modelWithDictionary:dic];
                [imgeUrlArr addObject:model.geiImg];
                [evaArr addObject:model];
            }
           _imgArray =  evaArr;
            self.comentImageArr = imgeUrlArr;
            }
    

    return YES;
}
// 如果实现了该方法，则处理过程中会忽略该列表内的所有属性
+ (NSArray *)modelPropertyBlacklist {
    return @[
             @"evaluateImgs",
             @"comentImageArr",
             @"imgArray"
             ];
}

-(NSString *)cellIdentifier{
    return @"GRGoodCommentCell";
}

-(CGFloat)myEvaluateHeight{
    CGFloat height = 135;
    if (NSStringNotNULL(self.geContent)&&![self.geContent isEqualToString:@""]) {
          height += [self.geContent boundingRectWithSize:CGSizeMake(KscreenWidth -25, MAXFLOAT) options:(NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:    [UIFont systemFontOfSize:15]} context:nil].size.height + 30;
    }
    if (self.imgArray.count >0) {
        height += (KscreenWidth-45)/3+35;
    }
    return height;
}

-(CGFloat)cellHeight{
    CGFloat height = 84;
    if(self.evaluateImgs.count >0){
        height += ((KscreenWidth - 50)/3)+15;
    }
    if (self.isDetailComment) {
        height += 55;
    }
    if (NSStringNotNULL(self.geContent)&&![self.geContent isEqualToString:@""]) {
        height += [self.geContent boundingRectWithSize:CGSizeMake(KscreenWidth -35, MAXFLOAT) options:(NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:    [UIFont systemFontOfSize:14]} context:nil].size.height;
    }

    return height;
}

@end



@implementation GRCommentImageModel

@end
